import React from 'react';
import ReactDOM from 'react-dom';

import { createHashHistory } from 'history';

import { Router, Route, useRouterHistory, IndexRedirect } from 'react-router';

import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';

import { Provider } from 'mobx-react';

import { WeaPopoverHrm, WeaLocaleProvider } from 'ecCom';

import Cowork from 'weaCowork'; // umd
// import Workflow from './index'

const CoworkStore = Cowork.store;
const routing = new RouterStore();
const CoworkRoute = Cowork.Route;
import CoworkSingle from './components/CoworkSingle';
import './style/single.less';

let stores = {
  // Key can be whatever you want
  routing,
  ...CoworkStore,
};

const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: '_key',
  basename: '/',
});

const history = syncHistoryWithStore(browserHistory, stores.routing);

class Home extends React.Component {
  render() {
    return (
      <div className="h100">
        <WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@vndle8`}>
        {this.props.children}
        </WeaLocaleProvider>
        <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@ytj0vc`} />
      </div>
    );
  }
}
const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'cowork');

class Root extends React.Component {
  render() {
    return (
      <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@1xfbo6`} {...stores}>
        <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@vbl29l`} history={history}>
          <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@biroze`} path="/" onEnter={getLocaleLabel} component={Home}>
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@4eoi6s`} name="main" breadcrumbName="入口" path="main">
              {CoworkRoute}
            </Route>
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@x30ndm`} name="cowork" path="cowork/:coworkId" component={CoworkSingle}>
              <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@t8z1ah`} path=":floorNum" />
            </Route>
            <IndexRedirect ecId={`${this && this.props && this.props.ecId || ''}_IndexRedirect@cdz6kv`} to="main/cowork/main" />
          </Route>
        </Router>
      </Provider>
    );
  }
}

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@1hordm`} />, document.getElementById('container'));
